package org.jeecg.modules.zhongjianku.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import org.jeecg.modules.lida.entity.ItemPO;
import org.jeecg.modules.zhongjianku.entity.YongHuXinXiPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*
* 卡号查人员详情（调用中间库接口）
* */
@Service
public class YongHuXinXiService {
    @Autowired
    private RestTemplate restTemplate;

    @Value("${JWang.serverUrl}")
    String serverUrl = "";

    public List<YongHuXinXiPO> selectInfoByMEMBER_CODE(String MEMBER_CODE) throws RestClientException {

        Map<String, Object> map = new HashMap() {{
            put("MEMBER_CODE", MEMBER_CODE);
        }};
        String str = restTemplate.postForObject("http://172.18.51.33:18081/sdata/rest/service/dataapi/rest/c85b624d-50bd-497e-9894-d1a861bdcf79",map,String.class);
        System.out.println(str);
        JSONObject jsonObject = (JSONObject) JSON.parse(str);
        JSONArray result = (JSONArray)jsonObject.get("result");
        System.out.println(result);
        List<YongHuXinXiPO> yongHuXinXiPOS =  JSONObject.parseArray(result.toString(),YongHuXinXiPO.class);
        System.out.println(yongHuXinXiPOS);
        return yongHuXinXiPOS;
    }
}
